
	<div id="action" class="easyui-dialog" closed="true" style="display:none;">
		<form class="easyui-form">
			<table>

				<tr id="seeS">
					<td>选择小区/栋：</td>
					<td>
						<button onClick='seeS()'>选择小区/栋</button>
					</td>
				</tr>

				<tr>
					<td>小区名称显示：</td>
					<td>
						<input type="text" id="cellName" disabled="disabled" style="float: left;">
					</td>
				</tr>

				<tr>
					<td>栋名称显示：</td>
					<td>
						<input type="text" id="buildingName" disabled="disabled" style="float: left;">
					</td>
				</tr>

				<tr>
					<td>房产名称：</td>
					<td>
						<input name='name' id="name" type="text" placeholder="输入房产名称">如：免中介宽带上网拧包入住大学生合租拧包入住
					</td>
				</tr>

				<tr>
					<td>房产房号：</td>
					<td>
						<input name='roomNumber' id="roomNumber" type="text" placeholder="输入房产房号">如：006C房
					</td>
				</tr>

				<tr>
					<td>房产租金：</td>
					<td>
						<input name='rent' id="rent" type="text" placeholder="输入房产租金">多少元/月
					</td>
				</tr>

				<tr>
					<td>房产建面：</td>
					<td>
						<input name='face' id="face" type="text" placeholder="输入房产建面">多少平方
					</td>
				</tr>

				<tr>
					<td>房产楼层：</td>
					<td>
						<input name='floor' id="floor" type="text" placeholder="输入房产楼层">在几楼
					</td>
				</tr>

				<tr>
					<td>房产方式：</td>
					<td>
						<select name="mode" id="mode">
							<option value="整租">整租</option>
							<option value="合租">合租</option>
							<option value="主卧">主卧</option>
							<option value="次卧">次卧</option>
							<option value="单间">单间</option>
							<option value="其他">其他</option>
						</select>
					</td>
				</tr>

				<tr>
					<td>房产户型：</td>
					<td>
						<input style='width:40px;' class='apartmentLayout' name='apartmentLayout001' id="apartmentLayout001" type="text" placeholder="几室">&nbsp;室&nbsp;&nbsp;
						<input style='width:40px;' class='apartmentLayout' name='apartmentLayout002' id="apartmentLayout002" type="text" placeholder="几厅">&nbsp;厅&nbsp;&nbsp;
						<input style='width:40px;' class='apartmentLayout' name='apartmentLayout003' id="apartmentLayout003" type="text" placeholder="几卫">&nbsp;卫&nbsp;&nbsp;
						<input style='width:40px;' class='apartmentLayout' name='apartmentLayout004' id="apartmentLayout004" type="text" placeholder="几厨">&nbsp;厨&nbsp;&nbsp;
					</td>
				</tr>

				<tr>
					<td>房产装修：</td>
					<td>
						<select name="renovation" id="renovation">
							<option value="毛坯">毛坯</option>
							<option value="简装修">简装修</option>
							<option value="中等装修">中等装修</option>
							<option value="精装修">精装修</option>
							<option value="豪华装修">豪华装修</option>
							<option value="其他">其他</option>
						</select>
					</td>
				</tr>

				<tr>
					<td>房产朝向：</td>
					<td>
						<select name="orientation" id="orientation">
							<option value="东">东</option>
							<option value="西">西</option>
							<option value="南">南</option>
							<option value="北">北</option>
							<option value="东南">东南</option>
							<option value="东北">东北</option>
							<option value="西南">西南</option>
							<option value="西北">西北</option>
							<option value="其他">其他</option>
						</select>
					</td>
				</tr>

				<tr>
					<td>房产配套设施：</td>
					<td>
						<input id="bed" name="bed" type="checkbox" value="bed" />床
						<input id="wardrobe" name="wardrobe" type="checkbox" value="wardrobe" />衣柜
						<input id="sofa" name="sofa" type="checkbox" value="sofa" />沙发
						<input id="television" name="television" type="checkbox" value="television" />电视
						<input id="refrigerator" name="refrigerator" type="checkbox" value="refrigerator" />冰箱
						<input id="washingMachine" name="washingMachine" type="checkbox" value="washingMachine" />洗衣机
						<input id="airConditioner" name="airConditioner" type="checkbox" value="airConditioner" />空调
						<input id="heater" name="heater" type="checkbox" value="heater" />热水器
						<input id="broadband" name="broadband" type="checkbox" value="broadband" />宽带
						<input id="balcony" name="balcony" type="checkbox" value="balcony" />阳台
						<input id="heating" name="heating" type="checkbox" value="heating" />暖气
						<input id="independentToilet" name="independentToilet" type="checkbox" value="independentToilet" />独立卫生间
						<input id="other" name="other" type="checkbox" value="other" />其他
					</td>
				</tr>

				<tr>
					<td>栋描述：</td>
					<td>
						<textarea name="describe" class="describe" style="width:75%;height:100px"></textarea>
					</td>
				</tr>

				<tr>
					<td>栋图片上传：</td>
					<td>
						<div>
							<input name='pic' id='pic' type="file" onchange="product.upPicMany(this)">
						</div>
					</td>
				</tr>

				<tr>
					<td>栋图片显示：</td>
					<td>
						<div id="picChild"></div>
					</td>
				</tr>

				<input type="hidden" id="buildingID">
				<input type="hidden" name="id" id='id'>

			</table>
		</form>

	</div>

	<script type="text/javascript">

		// 设置文本编辑器KindEditor
        KindEditor.ready(function(K) {

    		window.describe = K.create('.describe', {
            	uploadJson : '/ServicePic/picSave?dir=image'
            });
        });

		function submit(id){

			var method = "/daoHouse/houseAdd";
			if(id > 0){
				var method = "/daoHouse/houseSaveData";
			}

			var buildingID = $("#buildingID").val();
			var name = $("#name").val();
	        var roomNumber = $("#roomNumber").val();
	        var rent = $("#rent").val();
	        var face = $("#face").val();
	        var floor = $("#floor").val();
	        var mode = $("#mode").val();

	        var apartmentLayout001 = $("#apartmentLayout001").val();
	        var apartmentLayout002 = $("#apartmentLayout002").val();
	        var apartmentLayout003 = $("#apartmentLayout003").val();
	        var apartmentLayout004 = $("#apartmentLayout004").val();
			var apartmentLayout = new Array();
			apartmentLayout = {
				"room":apartmentLayout001,
				"office":apartmentLayout002,
				"wei":apartmentLayout003,
				"kitchen":apartmentLayout004,
			}
			var apartmentLayout  = JSON.stringify(apartmentLayout);

	        var renovation = $("#renovation").val();
	        var orientation = $("#orientation").val();

			// 多选
			var bed = $("#bed")[0].checked;
			var wardrobe = $("#wardrobe")[0].checked;
			var sofa = $("#sofa")[0].checked;
			var television = $("#television")[0].checked;
			var refrigerator = $("#refrigerator")[0].checked;
			var washingMachine = $("#washingMachine")[0].checked;
			var airConditioner = $("#airConditioner")[0].checked;
			var heater = $("#heater")[0].checked;
			var broadband = $("#broadband")[0].checked;
			var balcony = $("#balcony")[0].checked;
			var heating = $("#heating")[0].checked;
			var independentToilet = $("#independentToilet")[0].checked;
			var other = $("#other")[0].checked;
			var supportingFacilities = new Array();
			supportingFacilities = {
				"bed":bed,
				"wardrobe":wardrobe,
				"sofa":sofa,
				"television":television,
				"refrigerator":refrigerator,
				"washingMachine":washingMachine,
				"airConditioner":airConditioner,
				"heater":heater,
				"broadband":broadband,
				"balcony":balcony,
				"heating":heating,
				"independentToilet":independentToilet,
				"other":other,
			}
			var supportingFacilities  = JSON.stringify(supportingFacilities);

	        var describeTemporary = describe.html();

			// 图片上次错误提示
			picUrl = $('#picChild img').attr('src');
			/*if(picUrl == undefined){
				$.messager.alert('提示信息', "请上传多图片");
				return;
			}*/
			// 图片上传数据组合
			var picImg = new Array();
			$('.picImg').each(function(i, n){
				var src = $(this).attr('src');
				var savename = $(this).attr('savename');
				picImg[i] = {
					"firstPictureId":i,
					"firstPictureFileName":savename,
					"firstPictureAddress":src,
				}
			});
			var picture  = JSON.stringify(picImg);

	        $.messager.progress({msg:'正在增加...',interval:3000,});
			$.ajax({
				type:"post",
				url:method,
				data:{
					buildingID:buildingID,
					name:name,
					roomNumber:roomNumber,
					rent:rent,
					face:face,
					floor:floor,
					mode:mode,
					apartmentLayout:apartmentLayout,
					renovation:renovation,
					orientation:orientation,
					supportingFacilities:supportingFacilities,
					describe:describeTemporary,
					picture:picture,
					id:id,
				},
				cache: false,
				dataType:'html',
				success:function(data){

					var data = eval('('+data+')');
					if( data.info == 'success' ){
						
						$.messager.progress('close');
						$('#action').dialog('close');
						$('#data').datagrid('reload');
					} else {
						
						$.messager.progress('close');
						$.messager.alert('提示信息', data.info);
					}
				}
			});
		}

		function doAdd(id, data){

			$("#action form").form('reset');
			$("#picChild").html('');
			describe.html('');

			var title = '新增';

			$("#seeS").show();	// 171021. 判断重复值，选择的方案，无法关系两张表问题，最后只能选择关系一张表问题

			if(id > 0){
				var title = '修改';

				$("#seeS").hide(); // 171021. 判断重复值，选择的方案，无法关系两张表问题，最后只能选择关系一张表问题

				$("#cellName").val(data.cellName);
				$("#buildingName").val(data.buildingName);
				$("#name").val(data.name);
				$("#roomNumber").val(data.roomNumber);
				$("#rent").val(data.rent);
				$("#face").val(data.face);
				$("#floor").val(data.floor);
				$("#mode").val(data.mode);

				var apartmentLayout = jQuery.parseJSON(data.apartmentLayout);
				$("#apartmentLayout001").val(apartmentLayout.room);
				$("#apartmentLayout002").val(apartmentLayout.office);
				$("#apartmentLayout003").val(apartmentLayout.wei);
				$("#apartmentLayout004").val(apartmentLayout.kitchen);

				$("#renovation").val(data.renovation);
				$("#orientation").val(data.orientation);

				// 多选
				var supportingFacilities = jQuery.parseJSON(data.supportingFacilities);
				if(supportingFacilities.bed){
					$("#bed").attr("checked",true);
				}else{
					$("#bed").attr("checked",false);
				}
				if(supportingFacilities.wardrobe){
					$("#wardrobe").attr("checked",true);
				}else{
					$("#wardrobe").attr("checked",false);
				}
				if(supportingFacilities.sofa){
					$("#sofa").attr("checked",true);
				}else{
					$("#sofa").attr("checked",false);
				}
				if(supportingFacilities.television){
					$("#television").attr("checked",true);
				}else{
					$("#television").attr("checked",false);
				}
				if(supportingFacilities.refrigerator){
					$("#refrigerator").attr("checked",true);
				}else{
					$("#refrigerator").attr("checked",false);
				}
				if(supportingFacilities.washingMachine){
					$("#washingMachine").attr("checked",true);
				}else{
					$("#washingMachine").attr("checked",false);
				}
				if(supportingFacilities.airConditioner){
					$("#airConditioner").attr("checked",true);
				}else{
					$("#airConditioner").attr("checked",false);
				}
				if(supportingFacilities.heater){
					$("#heater").attr("checked",true);
				}else{
					$("#heater").attr("checked",false);
				}
				if(supportingFacilities.broadband){
					$("#broadband").attr("checked",true);
				}else{
					$("#broadband").attr("checked",false);
				}
				if(supportingFacilities.balcony){
					$("#balcony").attr("checked",true);
				}else{
					$("#balcony").attr("checked",false);
				}
				if(supportingFacilities.heating){
					$("#heating").attr("checked",true);
				}else{
					$("#heating").attr("checked",false);
				}
				if(supportingFacilities.independentToilet){
					$("#independentToilet").attr("checked",true);
				}else{
					$("#independentToilet").attr("checked",false);
				}
				if(supportingFacilities.other){
					$("#other").attr("checked",true);
				}else{
					$("#other").attr("checked",false);
				}

				$("#renovation").val(data.renovation);
				$("#buildingID").val(data.buildingID);

				describe.html(data.describe);

				// 多图
				var picture = jQuery.parseJSON(data.picture);
				for (var i = 0; i < picture.length; i++) {
					var productAddress = picture[i].firstPictureAddress;
					var productFileName = picture[i].firstPictureFileName;
					$('#picChild').append("<div class='picShowWrap' style='width:100px;height:100px;position:relative;display:inline-block;float:left;'>"
											+"<img class='picImg' width='100' height='100' src='"+productAddress+"' savename='"+productFileName+"'/>"
											+"<button onclick='product.movePicMany(this)' style='position: absolute;left:0px;bottom:0px'>左移</button>"
											+"<button onclick='product.removePic(this)' style='position: absolute;right:0px;bottom:0px'>删除</button>"
											+"</div>");
				}

				$("#id").val(data.id);

			}else{
				// authority.list();
			}

			$('#action').show();
			$('#action').dialog('open').dialog({
				title:title,    
				width:"100%",    
				height:"100%",
				closed:false,    
				cache:false,    
				modal:true,
				closable:true, 
				left:0,
				top:0,
				buttons:[{
					text:'确定',
					width:'56',
					handler:function(){

						submit(id);
					}
				},{
					text:'取消',
					width:'56',
					handler:function(){

						$('#action').dialog('close');
					}
				}],
			});
		}

		// 父窗口关闭弹框方法
        function parentWindowClosed(id, cellName, buildingName) {

        	$("#buildingID").val(id);
        	$("#cellName").val(cellName);
        	$("#buildingName").val(buildingName);
        	
            $("#bombBox").dialog("close");
            $('#data').datagrid('reload');   
        }

		// 弹框方法
		function seeS(id){

			var url = '/adminHouse/adminHouseAddBuilding';
			var content = '<iframe id="iframeBombBox" scrolling="auto" frameborder="0" src="'
						+ url + '" style="width:100%;height:100%;"></iframe>';
			$('#bombBox').dialog({
			    title: '用户',
			    width: '100%',
			    height: '100%',
			    modal: true,
			    content: content,
			    scroll: false,
			}); 
		}

	</script>
